package sisgel.user;

import sisgel.util.*;

public class User {

	protected int userId = -1;
	private String userName;
	private String login;
	private String password;
	private String phone;
	private String email;
	
	public User() {
		super();
	}
	
	public User(String userName, String login,
			String password, String phone, String email) {
		super();
		this.userName = userName;
		this.login = login;
		this.password = password;
		this.phone = phone;
		this.email = email;
		
		userId = saveUser();
	}
	
	public User(int userId, String userName, String login,
			String password, String phone, String email) {
		super();
		this.userId = userId;
		this.userName = userName;
		this.login = login;
		this.password = password;
		this.phone = phone;
		this.email = email;
	}
	
	public boolean login(String login, String password) {
		if (this.login.compareTo(login) == 0) 
			if (this.password.compareTo(password) == 0)
				return true;
		
		return false;
	}
	
	public int saveUser() {
		return DataBaseSQL.saveUser(this, password);
	}
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public int getUserId() {
		return userId;
	}
	
}
